package com.ruoyi.factory.manpower.controller;

import com.ruoyi.factory.manpower.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: LiuJiaji
 * @date: 2025/8/18 10:22
 * @description: TODO 考勤集成门禁系统
 * @param:
 * @return:
 **/
@EnableScheduling
@RestController("attendanceController")
@RequestMapping("/api/attendanceController")
public class AttendanceController {

    @Autowired
    private AttendanceService  attendanceService;

    /**
     * @author: LiuJiaji
     * @date: 2025/8/18 11:03
     * @description: TODO 考勤集成门禁
     * @param:
     * @return:
     **/
    @PostMapping("/attendanceAccess")
    public void attendanceAccess(@RequestBody String param){
        attendanceService.attendanceAccess2(param);
    }
    //7点到9点 每1分钟执行一次
    @Scheduled(cron="0 0/1 7-9 * * ?")
    public void attendanceAccess2(){
        attendanceService.attendanceAccess();
    }
    //16-19每一分钟执行一次
    @Scheduled(cron="0 0/1 16-19 * * ?")
    public void attendanceAccess3(){
        attendanceService.attendanceAccess();
    }
    //20点到23点每一小时执行一次
    @Scheduled(cron="0 0 20-23 * * ?")
    public void attendanceAccess4(){
        attendanceService.attendanceAccess();
    }
    //0点到6点每一小时执行一次
    @Scheduled(cron="0 0 0-6 * * ?")
    public void attendanceAccess5(){
        attendanceService.attendanceAccess();
    }
    //10点到14点每一小时执行一次
    @Scheduled(cron="0 0 10-15 * * ?")
    public void attendanceAccess6(){
        attendanceService.attendanceAccess();
    }
    //每小时执行一次5分5秒执行 查询昨天的数据
    @Scheduled(cron="5 5 0/1 1 1 ?")
    public void attendanceAccess7(){
        try {
            attendanceService.sendAccess2();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }






}
